package controller

import (
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
	"mygo/app/models"
	"mygo/app/tools"
)

type UserCtl struct {
	db *gorm.DB
}

var User = UserCtl{}

// getUser
func (ctl *UserCtl) GetUser(c *gin.Context) {
	ctl.db = models.Db
	var user models.User
	userId := c.Query("userId")
	ctl.db.Where("id = ?", userId).First(&user)
	if user.Username == "" {
		tools.ErrorResp(c, 500, "用户不存在")
		return
	}
	tools.SuccessResp(c, "获取成功", user)
}
